//
//  ComputerHouserVC.m
//  JinChengYun
//
//  Created by 金橙云 on 2017/5/18.
//  Copyright © 2017年 金橙云. All rights reserved.
//

#import "ComputerHouserVC.h"

#import "FTPopOverMenu.h"
@interface ComputerHouserVC ()

{
    NSInteger AA;
    NSInteger BB;
    UILabel *daLab;
    UILabel *zuoLab;
    UILabel *anZlab;
    UILabel *heLab;
    UILabel *daiLab;
    UILabel *daiFLab;
    UILabel *sHLab;
    UILabel *zhiLab;
    NSString* dateString;
    NSInteger HTZong;//合用总价
    NSInteger daiKZheng;//贷款数额整数
    NSInteger SELast;//贷款数额后四位
    NSInteger shouF;//首付金额
    NSInteger shouFHJ;//首付合计
    NSInteger daiSFXJ;//代收费用小计
    NSInteger Year;//下拉年限
    NSInteger Month;//月数
    CGFloat liLV;//下拉利率
    NSInteger BL;
    NSString *jieStr;
    NSString *biLIStr;
    NSString *shuStr;

}

@property(nonatomic,strong)NSMutableArray *anJieArr;
@property(nonatomic,strong)NSMutableDictionary *anDic;






@end

@implementation ComputerHouserVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"房贷计算器";
    self.view.backgroundColor =[UIColor grayColor];
     [self getCurrentTime];

   



    _anJieArr = [NSMutableArray array];
     _anDic = [NSMutableDictionary dictionary];
    
    _anJieArr = [_chDIc objectForKey:@"data"];
    NSLog(@"-----%@__-",[_chDIc objectForKey:@"dsf_string"]);
    
    _anDic = [_anJieArr objectAtIndex:0];
    
    //合同总价
    

    AA = 54.5;

    BB = (B_WIDTH-AA*3)/2;
    NSLog(@"========%@",_chDIc);
//    //基本信息
   [self setupMessage];
    [self setANChangYouHui];
    [self setupDaiKuanMessage];
   [self setupDaiShouMoney];
    [self setupShouFuAndGuWen];
//  
}

-(UIView *)allView
{
    if (_allView)
    {
        return _allView;
    }
    _allView = [[UIView alloc] initWithFrame:self.view.frame];
    _allView.backgroundColor = [UIColor grayColor];
    [self.view addSubview:_allView];
    return _allView;
}
//基本信息
-(void)setupMessage
{
    UILabel *nameLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 64, B_WIDTH, 29.5)];
    nameLab.backgroundColor = [UIColor colorWithHexString:@"#eb6200"];
  
    NSString *projectStr = [[NSUserDefaults standardUserDefaults] objectForKey:@"PROJECT_NAME"];
    NSLog(@"-----%@",projectStr);
    nameLab.text = [NSString stringWithFormat:@"  %@",projectStr] ;
    //nameLab.text = projectStr;
    nameLab.textColor = [UIColor whiteColor];
    nameLab.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:nameLab];
    
    zuoLab = [[UILabel alloc] init];
    zuoLab.textColor = [UIColor colorWithHexString:@"#eb6200"];
    zuoLab.backgroundColor = [UIColor whiteColor];
    zuoLab.text = @"基本信息";
    zuoLab.textAlignment = NSTextAlignmentCenter;
    zuoLab.numberOfLines = 2;
    zuoLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:zuoLab];
    [zuoLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA, 90));
        make.left.equalTo(self.view.mas_left).offset(0);
        make.top.equalTo(nameLab.mas_bottom).offset(0);
    }];
    
   //
    UILabel *houseLab = [[UILabel alloc] init];
    houseLab.backgroundColor = [UIColor whiteColor];
    houseLab.textColor = [UIColor blackColor];
    houseLab.text = @"房源位置";
    houseLab.textAlignment = NSTextAlignmentCenter;
    houseLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:houseLab];
    [houseLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA, 29.5));
        make.left.equalTo(zuoLab.mas_right).offset(0.5);
        make.top.equalTo(nameLab.mas_bottom).offset(0);
    }];
    
    _houNameLab = [[UILabel alloc] init];
    _houNameLab.backgroundColor = [UIColor whiteColor];
    _houNameLab.textColor = [UIColor blackColor];
    _houNameLab.text = [_chDIc objectForKey:@"name"];
    _houNameLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:_houNameLab];
    [_houNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(B_WIDTH-96, 29.5));
        make.left.equalTo(houseLab.mas_right).offset(0.5);
        make.top.equalTo(nameLab.mas_bottom).offset(0);

        
        
        
    }];

    
    UILabel *yMLab = [[UILabel alloc] init];
    yMLab.backgroundColor = [UIColor whiteColor];
    yMLab.textColor = [UIColor blackColor];
    yMLab.text = [_chDIc objectForKey:@"area_name"];
    yMLab.textAlignment = NSTextAlignmentCenter;
    yMLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:yMLab];
    [yMLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA, 29.5));
        make.left.equalTo(zuoLab.mas_right).offset(0.5);
        make.top.equalTo(_houNameLab.mas_bottom).offset(0.5);

        
        
    }];
   
    //预售面积
    _yuMianLab = [[UILabel alloc] init];
    _yuMianLab.backgroundColor = [UIColor whiteColor];
    _yuMianLab.textColor = [UIColor blackColor];
    _yuMianLab.text = [_chDIc objectForKey:@"sale_area"];
    _yuMianLab.textAlignment = NSTextAlignmentCenter;
    _yuMianLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:_yuMianLab];
    [_yuMianLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(BB, 29.5));
        make.left.equalTo(yMLab.mas_right).offset(0.5);
        make.top.equalTo(_houNameLab.mas_bottom).offset(0.5);
  
    }];

    //销售表价
    UILabel *shaoLab = [[UILabel alloc] init];
    shaoLab.backgroundColor = [UIColor whiteColor];
    shaoLab.textColor = [UIColor blackColor];
    shaoLab.text = @"销售表价";
    shaoLab.textAlignment = NSTextAlignmentCenter;
    shaoLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:shaoLab];
    [shaoLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA, 29.5));
        make.left.equalTo(_yuMianLab.mas_right).offset(0.5);
        make.top.equalTo(_houNameLab.mas_bottom).offset(0.5);
        
        
        
    }];

    _xBiaoLab = [[UILabel alloc] init];
    _xBiaoLab.backgroundColor = [UIColor whiteColor];
    _xBiaoLab.textColor = [UIColor blackColor];
    _xBiaoLab.text = [_chDIc objectForKey:@"sale_price"];
    _xBiaoLab.textAlignment = NSTextAlignmentCenter;
    _xBiaoLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:_xBiaoLab];
    [_xBiaoLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(BB, 29.5));
        make.left.equalTo(shaoLab.mas_right).offset(0.5);
        make.top.equalTo(_houNameLab.mas_bottom).offset(0.5);
        
        
        
    }];

    
    
    
     //表价总价
    UILabel *biaoLab = [[UILabel alloc] init];
    biaoLab.backgroundColor = [UIColor whiteColor];
    biaoLab.textColor = [UIColor blackColor];
    biaoLab.text = @"表价总价";
    biaoLab.textAlignment = NSTextAlignmentCenter;
    biaoLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:biaoLab];
    [biaoLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA, 29.5));
        make.left.equalTo(zuoLab.mas_right).offset(0.5);
        make.top.equalTo(_yuMianLab.mas_bottom).offset(0.5);
        
        
        
    }];

    _bZongLab = [[UILabel alloc] init];
    _bZongLab.backgroundColor = [UIColor whiteColor];
    _bZongLab.textColor = [UIColor blackColor];
    _bZongLab.text = [_chDIc objectForKey:@"sale_price_all"];;
    _bZongLab.textAlignment = NSTextAlignmentCenter;
    _bZongLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:_bZongLab];
    [_bZongLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(BB, 29.5));
        make.left.equalTo(biaoLab.mas_right).offset(0.5);
        make.top.equalTo(_yuMianLab.mas_bottom).offset(0.5);
        
        
        
    }];

    
    
   
    UILabel *fuLab = [[UILabel alloc] init];
    fuLab.backgroundColor = [UIColor whiteColor];
    fuLab.textColor = [UIColor blackColor];
    fuLab.text = @"付款方式";
    fuLab.textAlignment = NSTextAlignmentCenter;
    fuLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:fuLab];
    [fuLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA, 29.5));
        make.left.equalTo(_bZongLab.mas_right).offset(0.5);
        make.top.equalTo(_xBiaoLab.mas_bottom).offset(0.5);
        
        
        
    }];
    
    _payBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _payBtn.backgroundColor = [UIColor whiteColor];
    [_payBtn setImage:[UIImage imageNamed:@"btn_GraySan"] forState:0];
    _payBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    [_payBtn setTitle:@"按揭支付" forState:0];
    _payBtn.tag = 10;
    _payBtn.titleLabel.font = [UIFont systemFontOfSize:10];
    [_payBtn layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleRight imageTitleSpace:10];
    [_payBtn setTitleColor:[UIColor blackColor] forState:0];
    [_payBtn addTarget:self action:@selector(payStatueBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_payBtn];
    [_payBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(BB, 29.5));
        make.left.equalTo(fuLab.mas_right).offset(0.5);
        make.top.equalTo(_xBiaoLab.mas_bottom).offset(0.5);

    }];


}

//案场优惠,合同信息
-(void)setANChangYouHui
{
     anZlab= [[UILabel alloc] init];
    anZlab.backgroundColor = [UIColor whiteColor];
    anZlab.text = @"案场优惠";
    anZlab.textColor = [UIColor colorWithHexString:@"#eb6200"];
    anZlab.textAlignment = NSTextAlignmentCenter;
    anZlab.numberOfLines = 2;
    anZlab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:anZlab];
    [anZlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA, 35.5));
        make.left.equalTo(self.view.mas_left).offset(0);
        make.top.equalTo(zuoLab.mas_bottom).offset(0.5);

    }];
    
    _danJLab = [[UILabel alloc] init];
    _danJLab.text = [_anDic objectForKey:@"area_discount"];
    _danJLab.textColor = [UIColor blackColor];
    _danJLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:_danJLab];
    
    _zYouLab = [[UILabel alloc] init];
    _zYouLab.text =[_anDic objectForKey:@"cash_discount"];
    _zYouLab.textColor = [UIColor blackColor];
    _zYouLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:_zYouLab];
    
    _zBLab = [[UILabel alloc] init];
    _zBLab.text = [_anDic objectForKey:@"discount"];
    _zBLab.textColor = [UIColor blackColor];
    _zBLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:_zBLab];

    daLab = [[UILabel alloc] init];
    daLab.backgroundColor = [UIColor whiteColor];
   // daLab.text = [NSString stringWithFormat:@"  单价优惠:%@ 总价优惠:%@ 折扣比例:%@",_danJLab.text,_zYouLab.text,_zBLab.text];
    daLab.text = [_anDic objectForKey:@"acyh"];
    daLab.textColor = [UIColor blackColor];
    daLab.textAlignment = NSTextAlignmentLeft;
    daLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:daLab];
    [daLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(B_WIDTH - 40, 35.5));
        make.left.equalTo(anZlab.mas_right).offset(0.5);
        make.top.equalTo(_bZongLab.mas_bottom).offset(0.5);
        
    }];

    //合同信息
    heLab = [[UILabel alloc] init];
    heLab.backgroundColor = [UIColor whiteColor];
    heLab.text = @"合同信息";
    heLab.textColor = [UIColor colorWithHexString:@"#eb6200"];
    heLab.textAlignment = NSTextAlignmentCenter;
    heLab.numberOfLines = 2;
    heLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:heLab];
    [heLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA, 29.5));
        make.left.equalTo(self.view.mas_left).offset(0);
        make.top.equalTo(anZlab.mas_bottom).offset(0.5);
        
    }];

    
    UILabel *heFLab = [[UILabel alloc] init];
    heFLab.backgroundColor = [UIColor whiteColor];
    heFLab.textColor = [UIColor blackColor];
    heFLab.text = @"合同总价";
    heFLab.textAlignment = NSTextAlignmentCenter;
    heFLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:heFLab];
    [heFLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA, 29.5));
        make.left.equalTo(heLab.mas_right).offset(0.5);
        make.top.equalTo(daLab.mas_bottom).offset(0.5);
        
        
        
    }];
    
    _heZLab = [[UILabel alloc] init];
    _heZLab.backgroundColor = [UIColor whiteColor];
    _heZLab.textColor = [UIColor blackColor];
    _heZLab.text = [_anDic objectForKey:@"xieyi_price_all"];
    ;
    NSString *heTongStr = [_anDic objectForKey:@"xieyi_price_all"];
    //TODO:合同总价
    HTZong = [heTongStr intValue];
    _heZLab.textAlignment = NSTextAlignmentCenter;
    _heZLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:_heZLab];
    [_heZLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(BB, 29.5));
        make.left.equalTo(heFLab.mas_right).offset(0.5);
        make.top.equalTo(daLab.mas_bottom).offset(0.5);
        
        
        
    }];
    
    
    //合同单价
    UILabel *heDFLab = [[UILabel alloc] init];
    heDFLab.backgroundColor = [UIColor whiteColor];
    heDFLab.textColor = [UIColor blackColor];
    heDFLab.text = @"合同单价";
    heDFLab.textAlignment = NSTextAlignmentCenter;
    heDFLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:heDFLab];
    [heDFLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA, 29.5));
        make.left.equalTo(_heZLab.mas_right).offset(0.5);
        make.top.equalTo(daLab.mas_bottom).offset(0.5);
        
        
        
    }];
    
    _heDLab = [[UILabel alloc] init];
    _heDLab.backgroundColor = [UIColor whiteColor];
    _heDLab.textColor = [UIColor blackColor];
    _heDLab.text = [_anDic objectForKey:@"xieyi_price"];
    _heDLab.textAlignment = NSTextAlignmentCenter;
    _heDLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:_heDLab];
    [_heDLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(BB, 29.5));
        make.left.equalTo(heDFLab.mas_right).offset(0.5);
        make.top.equalTo(daLab.mas_bottom).offset(0.5);
        
        
        
    }];


    

}
//贷款信息
-(void)setupDaiKuanMessage
{
    daiLab = [[UILabel alloc] init];
    daiLab.backgroundColor = [UIColor whiteColor];
    daiLab.text = @"贷款信息";
    daiLab.textColor = [UIColor colorWithHexString:@"#eb6200"];
    daiLab.textAlignment = NSTextAlignmentCenter;
    daiLab.numberOfLines = 2;
    daiLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:daiLab];
    [daiLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA, 119.5));
        make.left.equalTo(self.view.mas_left).offset(0);
        make.top.equalTo(heLab.mas_bottom).offset(0.5);
        
    }];

    UILabel *dbFLab = [[UILabel alloc] init];
    dbFLab.backgroundColor = [UIColor whiteColor];
    dbFLab.textColor = [UIColor blackColor];
    dbFLab.text = @"贷款比例";
    dbFLab.textAlignment = NSTextAlignmentCenter;
    dbFLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:dbFLab];
    [dbFLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA, 29.5));
        make.left.equalTo(daiLab.mas_right).offset(0.5);
        make.top.equalTo(heLab.mas_bottom).offset(0.5);
        
        
        
    }];
    
   
    _daiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _daiBtn.backgroundColor = [UIColor whiteColor];
    [_daiBtn setImage:[UIImage imageNamed:@"btn_GraySan"] forState:0];
    _daiBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    [_daiBtn setTitle:@"70%" forState:0];
    _daiBtn.titleLabel.font = [UIFont systemFontOfSize:10];
    [_daiBtn layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleRight imageTitleSpace:10];
    [_daiBtn setTitleColor:[UIColor blackColor] forState:0];
    _daiBtn.tag = 11;
    [_daiBtn addTarget:self action:@selector(payStatueBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_daiBtn];
    [_daiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(BB, 29.5));
        make.left.equalTo(dbFLab.mas_right).offset(0.5);
        make.top.equalTo(heLab.mas_bottom).offset(0.5);
        
    }];


    //贷款年限
    UILabel *daiNFLab = [[UILabel alloc] init];
    daiNFLab.backgroundColor = [UIColor whiteColor];
    daiNFLab.textColor = [UIColor blackColor];
    daiNFLab.text = @"贷款年限";
    daiNFLab.textAlignment = NSTextAlignmentCenter;
    daiNFLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:daiNFLab];
    [daiNFLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA, 29.5));
        make.left.equalTo(_daiBtn.mas_right).offset(0.5);
        make.top.equalTo(heLab.mas_bottom).offset(0.5);
        
        
        
    }];
    
    _daiNBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _daiNBtn.backgroundColor = [UIColor whiteColor];
    [_daiNBtn setImage:[UIImage imageNamed:@"btn_GraySan"] forState:0];
    _daiNBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    [_daiNBtn setTitle:@"20年" forState:0];
     Month = 240;
    _daiNBtn.titleLabel.font = [UIFont systemFontOfSize:10];
    [_daiNBtn layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleRight imageTitleSpace:10];
    [_daiNBtn setTitleColor:[UIColor blackColor] forState:0];
    _daiNBtn.tag = 12;
    [_daiNBtn addTarget:self action:@selector(payStatueBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_daiNBtn];
    [_daiNBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(BB, 29.5));
        make.left.equalTo(daiNFLab.mas_right).offset(0.5);
        make.top.equalTo(heLab.mas_bottom).offset(0.5);
        
    }];
    
    //利率选择
    UILabel *liLLab = [[UILabel alloc] init];
    liLLab.backgroundColor = [UIColor whiteColor];
    liLLab.textColor = [UIColor blackColor];
    liLLab.text = @"利率选择";
    liLLab.textAlignment = NSTextAlignmentCenter;
    liLLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:liLLab];
    [liLLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA, 29.5));
        make.left.equalTo(daiLab.mas_right).offset(0.5);
        make.top.equalTo(dbFLab.mas_bottom).offset(0.5);
        
        
        
    }];

    _liLvBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _liLvBtn.backgroundColor = [UIColor whiteColor];
    [_liLvBtn setImage:[UIImage imageNamed:@"btn_GraySan"] forState:0];
    _liLvBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    [_liLvBtn setTitle:@"      最新基础利率    " forState:0];
    
    liLV = 0.049/12;
    _liLvBtn.titleLabel.font = [UIFont systemFontOfSize:10];
    [_liLvBtn layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleRight imageTitleSpace:20];
    [_liLvBtn setTitleColor:[UIColor blackColor] forState:0];
    _liLvBtn.tag = 13;
    [_liLvBtn addTarget:self action:@selector(payStatueBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_liLvBtn];
    [_liLvBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(B_WIDTH-AA-30, 29.5));
        make.left.equalTo(liLLab.mas_right).offset(0.5);
        make.top.equalTo(_daiNBtn.mas_bottom).offset(0.5);
        
    }];
    
    
    UILabel *sfLab = [[UILabel alloc] init];
    sfLab.backgroundColor = [UIColor whiteColor];
    sfLab.textColor = [UIColor blackColor];
    sfLab.text = @"首付金额";
    sfLab.textAlignment = NSTextAlignmentCenter;
    sfLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:sfLab];
    [sfLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA, 29.5));
        make.left.equalTo(daiLab.mas_right).offset(0.5);
        make.top.equalTo(liLLab.mas_bottom).offset(0.5);
        
        
        
    }];

    _shouFLab = [[UILabel alloc] init];
    _shouFLab.backgroundColor = [UIColor whiteColor];
    _shouFLab.textColor = [UIColor redColor];
    


    _shouFLab.textAlignment = NSTextAlignmentCenter;
    _shouFLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:_shouFLab];
    [_shouFLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(BB, 29.5));
        make.left.equalTo(sfLab.mas_right).offset(0.5);
        make.top.equalTo(liLLab.mas_bottom).offset(0.5);
        
        
        
    }];

    UILabel *dsLab = [[UILabel alloc] init];
    dsLab.backgroundColor = [UIColor whiteColor];
    dsLab.textColor = [UIColor blackColor];
    dsLab.text = @"贷款数额";
    dsLab.textAlignment = NSTextAlignmentCenter;
    dsLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:dsLab];
    [dsLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA, 29.5));
        make.left.equalTo(_shouFLab.mas_right).offset(0.5);
        make.top.equalTo(liLLab.mas_bottom).offset(0.5);
        
        
        
    }];
    

    _daiSLab = [[UILabel alloc] init];
    _daiSLab.backgroundColor = [UIColor whiteColor];
    _daiSLab.textColor = [UIColor redColor];
     //TODO:默认贷款数额
    NSInteger daiZ = 0.7*HTZong;
    NSLog(@"-----he总价-----%ld",HTZong);
    NSLog(@"-----daikain-----%ld",daiZ);
   shuStr = [NSString stringWithFormat:@"%ld",(long)daiZ];
    NSLog(@"---------shuStr-------%@",shuStr);
    _daiSLab.text = [NSString stringWithFormat:@"%@",[self stringTointerCept:shuStr]];
    //NSInteger 类型   贷款数额
    daiKZheng = [_daiSLab.text intValue];
    NSLog(@"------贷款证书----%ld",daiKZheng);
    NSString *houStr = [NSString stringWithFormat:@"%@",[self stringGetLastFour:shuStr]];
    SELast = [houStr intValue];
     NSLog(@"=========SELast--------%ld",(long)SELast);
    
        //TODO:  默认首付金额
    shouF = HTZong - daiKZheng;
    _shouFLab.text = [NSString stringWithFormat:@"%ld",(long)shouF];
    NSLog(@"------%ld---",shouF);
    
    
    _daiSLab.textAlignment = NSTextAlignmentCenter;
    _daiSLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:_daiSLab];
    [_daiSLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(BB, 29.5));
        make.left.equalTo(dsLab.mas_right).offset(0.5);
        make.top.equalTo(liLLab.mas_bottom).offset(0.5);
        
        
        
    }];

    ////月供金额
    UILabel *yueLab =  [[UILabel alloc] init];
    yueLab.backgroundColor = [UIColor whiteColor];
    yueLab.textColor = [UIColor blackColor];
    yueLab.text = @"月供金额";
    yueLab.textAlignment = NSTextAlignmentCenter;
    yueLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:yueLab];
    [yueLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA, 29.5));
        make.left.equalTo(daiLab.mas_right).offset(0.5);
        make.top.equalTo(sfLab.mas_bottom).offset(0.5);
        
        
        
    }];
    
    _yueJLab =  [[UILabel alloc] init];
    _yueJLab.backgroundColor = [UIColor whiteColor];
    _yueJLab.textColor = [UIColor redColor];
    _yueJLab.text = @"0";
    _yueJLab.textAlignment = NSTextAlignmentCenter;
    _yueJLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:_yueJLab];
    [_yueJLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(B_WIDTH-AA-30, 29.5));
        make.left.equalTo(yueLab.mas_right).offset(0.5);
        make.top.equalTo(sfLab.mas_bottom).offset(0.5);
        
        
        
    }];

    
    
}
//代收费用
-(void)setupDaiShouMoney
{
    daiFLab = [[UILabel alloc] init];
    daiFLab.backgroundColor = [UIColor whiteColor];
    daiFLab.text = @"代收费用";
    daiFLab.textColor = [UIColor colorWithHexString:@"#eb6200"];
    daiFLab.textAlignment = NSTextAlignmentCenter;
    daiFLab.numberOfLines = 2;
    daiFLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:daiFLab];
    [daiFLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA, 73.5));
        make.left.equalTo(self.view.mas_left).offset(0);
        make.top.equalTo(daiLab.mas_bottom).offset(0.5);
        
    }];

    
    UILabel *weiXLab = [[UILabel alloc] init];
    weiXLab.backgroundColor = [UIColor whiteColor];
    weiXLab.textColor = [UIColor blackColor];
    weiXLab.text =[_chDIc objectForKey:@"dsf_string"];
    weiXLab.numberOfLines = 2;
    weiXLab.textAlignment = NSTextAlignmentCenter;
    weiXLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:weiXLab];
    [weiXLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(B_WIDTH-AA, 36.5));
        make.left.equalTo(daiLab.mas_right).offset(0.5);
        make.top.equalTo(daiLab.mas_bottom).offset(0.5);
        
        
        
    }];

    
    
    //代收费用小计
    _daiSMLab = [[UILabel alloc] init];
    _daiSMLab.backgroundColor = [UIColor whiteColor];
    _daiSMLab.textColor = [UIColor blackColor];
    NSString *allStr = [_chDIc objectForKey:@"dsf_all"];
    _daiSMLab.text =[NSString stringWithFormat:@" 代收费用小计: %@",allStr];
    daiSFXJ = [allStr intValue];
   // NSLog(@"---------daiSFXJ--------%ld",(long)daiSFXJ);
    _daiSMLab.textAlignment = NSTextAlignmentLeft;
    _daiSMLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:_daiSMLab];
    [_daiSMLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(B_WIDTH-AA, 36.5));
        make.left.equalTo(daiLab.mas_right).offset(0.5);
        make.top.equalTo(weiXLab.mas_bottom).offset(0.5);
        
        
        
    }];
 
}
//首付合计&&置业顾问
-(void)setupShouFuAndGuWen
{
    sHLab = [[UILabel alloc] init];
    sHLab.backgroundColor = [UIColor whiteColor];
    sHLab.text = @"首付合计";
    sHLab.textColor = [UIColor colorWithHexString:@"#eb6200"];
    sHLab.textAlignment = NSTextAlignmentCenter;
    sHLab.numberOfLines = 2;
    sHLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:sHLab];
    [sHLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA, 29.5));
        make.left.equalTo(self.view.mas_left).offset(0);
        make.top.equalTo(daiFLab.mas_bottom).offset(0.5);
        
    }];
    
    _shouHLab = [[UILabel alloc] init];
    _shouHLab.backgroundColor = [UIColor whiteColor];
    _shouHLab.textColor = [UIColor redColor];
    
    //TODO:默认首付合计
    shouFHJ = shouF + daiSFXJ;
    _shouHLab.text =[NSString stringWithFormat:@"%ld",(long)shouFHJ];
    
    _shouHLab.textAlignment = NSTextAlignmentCenter;
    _shouHLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:_shouHLab];
    [_shouHLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(B_WIDTH-AA, 29.5));
        make.left.equalTo(sHLab.mas_right).offset(0.5);
        make.top.equalTo(daiFLab.mas_bottom).offset(0.5);
   
        
    }];

    
    
    
    zhiLab = [[UILabel alloc] init];
    zhiLab.backgroundColor = [UIColor whiteColor];
    zhiLab.text = @"置业顾问";
    zhiLab.textColor = [UIColor colorWithHexString:@"#eb6200"];
    zhiLab.textAlignment = NSTextAlignmentCenter;
    zhiLab.numberOfLines = 2;
    zhiLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:zhiLab];
    [zhiLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA, 29.5));
        make.left.equalTo(self.view.mas_left).offset(0);
        make.top.equalTo(sHLab.mas_bottom).offset(0.5);
        
    }];
    
    
    
    UILabel *nameLab = [[UILabel alloc] init];
    nameLab.backgroundColor = [UIColor whiteColor];
    nameLab.textColor = [UIColor blackColor];
   NSString *nameStr = [[NSUserDefaults standardUserDefaults] objectForKey:@"LOGIN_NAME"];
    nameLab.text = nameStr;
    nameLab.textAlignment = NSTextAlignmentCenter;
    nameLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:nameLab];
    [nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA+BB, 29.5));
        make.left.equalTo(zhiLab.mas_right).offset(0.5);
        make.top.equalTo(sHLab.mas_bottom).offset(0.5);
        
        
    }];

    UILabel *dataLab =[[UILabel alloc] init];
    dataLab.backgroundColor = [UIColor whiteColor];
    dataLab.textColor = [UIColor blackColor];
    dataLab.text =dateString;
  
    dataLab.textAlignment = NSTextAlignmentCenter;
    dataLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:dataLab];
    [dataLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(AA+BB, 29.5));
        make.left.equalTo(nameLab.mas_right).offset(0.5);
        make.top.equalTo(sHLab.mas_bottom).offset(0.5);
        
        
    }];

    UILabel *lastLab = [[UILabel alloc] init];
    lastLab.backgroundColor = [UIColor whiteColor];
    lastLab.textColor = [UIColor blackColor];
    lastLab.text =@" *说明:以上价格当日有效,利率和月供仅供参考.";
    lastLab.textAlignment = NSTextAlignmentLeft;
    lastLab.font = [UIFont systemFontOfSize:10];
    [self.view addSubview:lastLab];
    [lastLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(B_WIDTH, 29.5));
        make.left.equalTo(self.view.mas_left).offset(0);
        make.top.equalTo(zhiLab.mas_bottom).offset(0.5);
        
        
    }];
    
    
    UIView *writeView = [[UIView alloc] init];
    writeView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:writeView];
    [writeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(B_WIDTH, 360));
        make.left.equalTo(self.view.mas_left).offset(0);
        make.top.equalTo(lastLab.mas_bottom).offset(0);
    }];
    
    NSInteger GG = 20;
    NSInteger EE = (B_WIDTH-20*3)/2;
    
    UIButton *startBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    startBtn.backgroundColor = [UIColor orangeColor];
    startBtn.layer.cornerRadius = 5;
    [startBtn setTitle:@"开始计算" forState:0];
    [startBtn addTarget:self action:@selector(startBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [startBtn setTitleColor:[UIColor whiteColor] forState:0];
    [self.view addSubview:startBtn];
    [startBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(EE, 40));
        make.left.equalTo(self.view.mas_left).offset(GG);
        make.top.equalTo(lastLab.mas_bottom).offset(15);
    }];
    
    
    UIButton *chongBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    chongBtn.backgroundColor = [UIColor orangeColor];
    [chongBtn setTitle:@"重置" forState:0];
     chongBtn.layer.cornerRadius = 5;
    [chongBtn setTitleColor:[UIColor whiteColor] forState:0];
    [chongBtn addTarget:self action:@selector(chongBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:chongBtn];
    [chongBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(EE, 40));
        make.left.equalTo(startBtn.mas_right).offset(GG);
        make.top.equalTo(lastLab.mas_bottom).offset(15);
    }];

}



#pragma mark 付款方式 下拉框的选择
-(void)payStatueBtnClick:(UIButton *)sender
{
      Year = 20;
    NSArray *menuNameArray = @[@"按揭支付",@"全款支付"];
    NSArray *daiBArr = @[@"10%",@"20%",@"30%",@"40%",@"50%",@"60%",@"70%"];
    NSArray *daiNArr = @[@"1年",@"2年",@"3年",@"4年",@"5年",@"6年",@"7年",@"8年",@"9年",@"10年",@"11年",@"12年",@"13年",@"14年",@"15年",@"16年",@"17年",@"18年",@"19年",@"20年",@"21年",@"22年",@"23年",@"24年",@"25年",@"26年",@"27年",@"28年",@"29年",@"30年",];
    NSArray *lvArr= @[@"最新基础利率",@"最新基础利率7折",@"最新基础利率8折",@"最新基础利率8.3折",@"最新基础利率8.5折",@"最新基础利率8.8折",@"最新基础利率9折",@"最新基础利率9.5折",@"最新基础利率1.05倍",@"最新基础利率1.1倍",@"最新基础利率1.2倍",@"最新基础利率1.3倍",@"公积金最新基准利率"];
    if (sender.tag == 10)
    {
        [FTPopOverMenu showForSender:sender
                       withMenuArray:menuNameArray
                          imageArray:nil
                           doneBlock:^(NSInteger selectedIndex) {
                               
                               [sender setTitle:menuNameArray[selectedIndex] forState:UIControlStateNormal];
                               
                               //按揭OR全款
                               jieStr = menuNameArray[selectedIndex];
                               if ([jieStr isEqualToString:@"全款支付"])
                               {

                                   NSLog(@"zhegsi全款执法");
                                   //TODO:------全款支付--------
                                   //首付金额
                                   _shouFLab.text = [_anDic objectForKey:@"xieyi_price_all"];
                                   //贷款比例
                                   [_daiBtn setTitle:@"无" forState:0];
                                   ///贷款年限
                                     [_daiNBtn setTitle:@"无" forState:0];
                                   //利率选择
                                   
                                    [_liLvBtn setTitle:@"    无 " forState:0];
                                   //贷款数额
                                   _daiSLab.text =@"0";
                                   //月供金额
                                   _yueJLab.text = @"0";
                                   //首付合计
                                   NSString *daiStr = [_chDIc objectForKey:@"dsf_all"];// 代数费用
                                   NSString *shouStr = [_anDic objectForKey:@"xieyi_price_all"];
                                   NSInteger daiAA = [daiStr intValue];
                                   NSInteger ShouBB = [shouStr intValue];
                                   NSInteger SZ = daiAA + ShouBB;
                                   _shouHLab.text =[NSString stringWithFormat:@"%ld",(long)SZ];
                                   
                               }
                               else
                               {
                              
                                   
                                   //首付金额
                                   _shouFLab.text = [_anDic objectForKey:@"xieyi_price_all"];
                                   //贷款比例
                                   [_daiBtn setTitle:@"70%" forState:0];
                                   ///贷款年限
                                   [_daiNBtn setTitle:@"20年 " forState:0];
                                   //利率选择
                                   [_liLvBtn setTitle:@"      最新基础利率    " forState:0];
                                   //贷款数额
                                   _daiSLab.text = [NSString stringWithFormat:@"%@",[self stringTointerCept:shuStr]];
                                   //月供金额
                                   _yueJLab.text = @"0";
                                   //首付合计
                                   shouFHJ = shouF + daiSFXJ;
                                   _shouHLab.text =[NSString stringWithFormat:@"%ld",(long)shouFHJ];                             }
                               
                           } dismissBlock:^{
                               
                           }];
        
    }
    if (sender.tag == 11)
    {
        [FTPopOverMenu showForSender:sender
                       withMenuArray:daiBArr
                          imageArray:nil
                           doneBlock:^(NSInteger selectedIndex) {
                               
                               [sender setTitle:daiBArr[selectedIndex] forState:UIControlStateNormal];
                               NSString *daiStr = daiBArr[selectedIndex];
                               //TODO: 点击之后贷款比例
                               BL = [daiStr intValue];
                            
                               NSInteger zongE = (BL *0.01)*HTZong;
                               NSString *zoE = [NSString stringWithFormat:@"%ld",zongE];
                               _daiSLab.text = [NSString stringWithFormat:@"%@",[self stringTointerCept:zoE]];
                               
                              daiKZheng = [_daiSLab.text intValue];
                               
                               
                               //TODO: 点击之后首付金额
                               
                               NSInteger dShouF = HTZong - daiKZheng;
                               _shouFLab.text = [NSString stringWithFormat:@"%ld",dShouF];
                               
                              //TODO: 点击之后首付合计
                             
                               NSInteger shouFH = dShouF +daiSFXJ;
                               _shouHLab.text = [NSString stringWithFormat:@"%ld",shouFH];
                               
                               
                            
                               
                           } dismissBlock:^{
                               
                           }];
        
    }if (sender.tag == 12)
    {
        [FTPopOverMenu showForSender:sender
                       withMenuArray:daiNArr
                          imageArray:nil
                           doneBlock:^(NSInteger selectedIndex) {
                               
                               [sender setTitle:daiNArr[selectedIndex] forState:UIControlStateNormal];
                               
                             
                               //贷款年限
                               NSString *yearStr = daiNArr[selectedIndex];
                               //NSLog(@"------默认-------%@",yearStr);
                               Year = [yearStr intValue];
                               
                          NSLog(@"-----year-------%ld",Year);
                               if (selectedIndex)
                               {
                                   
                                   Month = [self YearOrMonth:selectedIndex];
                                   NSLog(@"---------------多少月------%ld",Month);
                                   
                               }

                           } dismissBlock:^{
                               
                           }];

        
    }if (sender.tag == 13)
    {
        [FTPopOverMenu showForSender:sender
                       withMenuArray:lvArr
                          imageArray:nil
                           doneBlock:^(NSInteger selectedIndex) {
                               
                               [sender setTitle:lvArr[selectedIndex] forState:UIControlStateNormal];
                             
                               if (selectedIndex == 1)
                               {
                                   if (Year <= 5 && Year >1)
                                   {
                                        liLV = (0.0475/12)*0.7;
                                       
                                   }
                                   if (Year == 1)
                                   {
                                       liLV = (0.0435/12)*0.7;
                                     
                                   }
                                   
                                   if (Year >5)
                                   {
                                       liLV = (0.049/12)*0.7;
                                       // NSLog(@"-----这是多少-----%f",liLV);
                                   }
                                  
                                  
                               }
                               
                               else if (selectedIndex == 2)
                               {
                                   if (Year <= 5 && Year >1)
                                   {
                                       liLV = (0.0475/12)*0.8;
    
                                   }
                                   if (Year == 1)
                                   {
                                       liLV = (0.0435/12)*0.8;
                                      // NSLog(@"-----2-----%f",liLV);
                                   }
                                   
                                   if (Year >5)
                                   {
                                       liLV = (0.049/12)*0.8;
                                     //  NSLog(@"-----3-----%f",liLV);
                                   }
                                   
                               }
                               else if (selectedIndex == 3)
                               {
                                   if (Year <= 5 && Year >1)
                                   {
                                       liLV = (0.0475/12)*0.83;
                                       
                                   }
                                   if (Year == 1)
                                   {
                                       liLV = (0.0435/12)*0.83;
                                       //NSLog(@"-----2-----%f",liLV);
                                   }
                                   
                                   if (Year >5)
                                   {
                                       liLV = (0.049/12)*0.83;
                                     //  NSLog(@"-----3-----%f",liLV);
                                   }
                                   
                               }

                              else if (selectedIndex == 4)
                               {
                                   if (Year <= 5 && Year >1)
                                   {
                                       liLV = (0.0475/12)*0.85;
                                       
                                   }
                                   if (Year == 1)
                                   {
                                       liLV = (0.0435/12)*0.85;
                                     //  NSLog(@"-----2-----%f",liLV);
                                   }
                                   
                                   if (Year >5)
                                   {
                                       liLV = (0.049/12)*0.85;
                                      // NSLog(@"-----3-----%f",liLV);
                                   }
                                   
                               }

                              else if (selectedIndex == 5)
                               {
                                   if (Year <= 5 && Year >1)
                                   {
                                       liLV = (0.0475/12)*0.88;
                                       
                                   }
                                   if (Year == 1)
                                   {
                                       liLV = (0.0435/12)*0.88;
                                      // NSLog(@"-----2-----%f",liLV);
                                   }
                                   
                                   if (Year >5)
                                   {
                                       liLV = (0.049/12)*0.88;
                                      // NSLog(@"-----3-----%f",liLV);
                                   }
                                   
                               }

                              else if (selectedIndex == 6)
                               {
                                   if (Year <= 5 && Year >1)
                                   {
                                       liLV = (0.0475/12)*0.9;
                                       
                                   }
                                   if (Year == 1)
                                   {
                                       liLV = (0.0435/12)*0.9;
                                      // NSLog(@"-----2-----%f",liLV);
                                   }
                                   
                                   if (Year >5)
                                   {
                                       liLV = (0.049/12)*0.9;
                                      // NSLog(@"-----3-----%f",liLV);
                                   }
                                   
                               }

                              else if (selectedIndex == 7)
                               {
                                   if (Year <= 5 && Year >1)
                                   {
                                       liLV = (0.0475/12)*0.95;
                                       
                                   }
                                   if (Year == 1)
                                   {
                                       liLV = (0.0435/12)*0.95;
                                      // NSLog(@"-----2-----%f",liLV);
                                   }
                                   
                                   if (Year >5)
                                   {
                                       liLV = (0.049/12)*0.95;
                                      // NSLog(@"-----3-----%f",liLV);
                                   }
                                   
                               }

                              else if (selectedIndex == 8)
                               {
                                   if (Year <= 5 && Year >1)
                                   {
                                       liLV = (0.0475/12)*1.05;
                                       
                                   }
                                   if (Year == 1)
                                   {
                                       liLV = (0.0435/12)*1.05;
                                      // NSLog(@"-----2-----%f",liLV);
                                   }
                                   
                                   if (Year >5)
                                   {
                                       liLV = (0.049/12)*1.05;
                                       //NSLog(@"-----3-----%f",liLV);
                                   }
                                   
                               }

                             else  if (selectedIndex == 9)
                               {
                                   if (Year <= 5 && Year >1)
                                   {
                                       liLV = (0.0475/12)*1.1;
                                       
                                   }
                                   if (Year == 1)
                                   {
                                       liLV = (0.0435/12)*1.1;
                                       //NSLog(@"-----2-----%f",liLV);
                                   }
                                   
                                   if (Year >5)
                                   {
                                       liLV = (0.049/12)*1.1;
                                      // NSLog(@"-----3-----%f",liLV);
                                   }
                                   
                               }
                               else if (selectedIndex == 10)
                               {
                                   if (Year <= 5 && Year >1)
                                   {
                                       liLV = (0.0475/12)*1.2;
                                       
                                   }
                                   if (Year == 1)
                                   {
                                       liLV = (0.0435/12)*1.2;
                                      // NSLog(@"-----2-----%f",liLV);
                                   }
                                   
                                   if (Year >5)
                                   {
                                       liLV = (0.049/12)*1.2;
                                      // NSLog(@"-----3-----%f",liLV);
                                   }
                                   
                               }

                              else if (selectedIndex == 11)
                               {
                                   if (Year <= 5 && Year >1)
                                   {
                                       liLV = (0.0475/12)*1.3;
                                       
                                   }
                                   if (Year == 1)
                                   {
                                       liLV = (0.0435/12)*1.3;
                                       //NSLog(@"-----2-----%f",liLV);
                                   }
                                   
                                   if (Year >5)
                                   {
                                       liLV = (0.049/12)*1.3;
                                      // NSLog(@"-----3-----%f",liLV);
                                   }
                                   
                               }
                              else if (selectedIndex == 12)
                               {
                                   //公积金
                                   if (Year <= 5)
                                   {
                                       liLV = 0.0275/12;
                                       
                                   }
                                   
                                   if (Year >5)
                                   {
                                       liLV = 0.0325/12;
                                      // NSLog(@"-----3-----%f",liLV);
                                   }
                                   
                               }
                               else
                               {
                                   if (Year <= 5 && Year >1)
                                   {
                                       liLV = 0.0475/12;
                                       
                                   }
                                   if (Year == 1)
                                   {
                                       liLV = 0.0435/12;
                                       NSLog(@"-----2-----%f",liLV);
                                   }
                                   
                                   if (Year >5)
                                   {
                                       liLV = 0.049/12;
                                       NSLog(@"-----3-----%f",liLV);
                                   }
                               }



                          
                               
                           } dismissBlock:^{
                               
                           }];
        
    }



}

#pragma mark  开始计算
-(void)startBtnClick:(UIButton *)btn
{
    NSLog(@"--------贷款数额------%ld",daiKZheng);
    NSLog(@"------liLV-----%f------",liLV);
    float aa = (1+liLV);
    double bb = pow(aa, Month);

 
    CGFloat shang = liLV*bb;
    CGFloat xia = bb - 1;
    CGFloat Zong = (shang/xia)*daiKZheng;
//    NSLog(@"----sahng-----------%f",shang);
//    NSLog(@"----xia-----------%f",xia);
   NSLog(@"----月供金额-----------%f",Zong);
//

    NSString *yueJStr = [NSString stringWithFormat:@"%f",Zong];
    _yueJLab.text =[NSString stringWithFormat:@"%@",[self removeFloatAllZero:yueJStr]];


}

#pragma mark  重置
-(void)chongBtnClick:(UIButton *)btn
{
    //贷款比例
     [_daiBtn setTitle:@"70%" forState:0];
    //贷款年限
    [_daiNBtn setTitle:@"20年" forState:0];
    //贷款数额
    NSInteger daiZ = 0.7*HTZong;
    NSString *shuStr = [NSString stringWithFormat:@"%ld",daiZ];
    NSLog(@"---------shuStr-------%@",shuStr);
    _daiSLab.text = [NSString stringWithFormat:@"%@",[self stringTointerCept:shuStr]];

   //首付金额
    //TODO:  默认首付金额
    shouF = HTZong - daiKZheng;
    _shouFLab.text = [NSString stringWithFormat:@"%ld",shouF];

    //月供金额
    
    //首付合计
    shouFHJ = shouF + daiSFXJ;
    _shouHLab.text =[NSString stringWithFormat:@"%ld",shouFHJ];

     _yueJLab.text = @"0";
    
    
    
    
    
}
#pragma -mark -获取现在的日历时间  输出形式 2014-06-27 15:41:55
- (NSString *) getCurrentTime
{
    
    NSDate* date = [NSDate date];
    
    //日历为阳历
    NSCalendar *calendar = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];
    //表示一个日期对象的组件
    NSDateComponents *component = [calendar components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond fromDate:date];
    //设定时区
    [component setTimeZone:[NSTimeZone systemTimeZone]];
    
    NSInteger year = [component year];
    NSInteger month = [component month];
    NSInteger day = [component day];

    
     dateString = [NSString stringWithFormat:@"%li-%@%li-%@%li " , (long)year , month > 10 ? @"" :@"0",(long)month , day > 10 ? @"" :@"0", (long)day ];
    return dateString;
    
}


#pragma mark 省略千后边数字
-(NSString *)stringTointerCept:(NSString *)str
{
    NSLog(@"-----传过来是什么-----%@",str);
    NSInteger len = [str length];
    NSLog(@"======有什么=====%ld",len);
    if ([str rangeOfString:@"."].location != NSNotFound)
    {
        NSArray *array = [str componentsSeparatedByString:@"."];
        return [NSString stringWithFormat:@"%@0000",[array[0] substringToIndex:len-4]];
    }
    else
    {
        return [NSString stringWithFormat:@"%@0000",[str substringToIndex:len-4]];
    }
    

}

#pragma mark 获取千后边数字
-(NSString *)stringGetLastFour:(NSString *)string
{
    NSInteger lon = [string length];
    if (lon>4)
    {
        if ([string rangeOfString:@"."].location != NSNotFound)
        {
            NSArray *arr = [string componentsSeparatedByString:@"."];
            return [NSString stringWithFormat:@"%@",[arr[0] substringFromIndex:lon-4]];
        }
        else
        {
            return [NSString stringWithFormat:@"%@",[string substringFromIndex:lon-4]];
        }
    }
    else
    {
        return string;
    }
    
}

#pragma mark 年转成月
-(NSInteger )YearOrMonth:(NSInteger)number
{
    if (number != 0)
    {
        return (number+1)*12;;
    }
    else
    {
        return 12;
    }
   
}

#pragma mark 去掉小数点后边数字
-(NSString*)removeFloatAllZero:(NSString*)string
{
    NSString * testNumber = string;
    NSString * outNumber = [NSString stringWithFormat:@"%@",@(testNumber.intValue)];
    return outNumber;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
